﻿#region Usings

using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Rail.Net.Common.Model;
using Rail.Net.Common.Resources;

#endregion

namespace Rail.Net.Core.Model.Nonpersistent
{
    /// <summary>
    ///   Represents a travelers model.
    ///   Contatins information like: Traveler's age and Traveler's discount
    /// </summary>
    [Serializable]
    [DataContract]
    public class TravelerModel : IEquatable<TravelerModel>
    {
        /// <summary>
        ///   Traveler's age
        /// </summary>
        [Display(ResourceType = typeof (Global), Name = "MainModel_Traveler_Age")]
        [DataMember]
        public ListableItem Age { get; set; }

        /// <summary>
        ///   Traveler's discount
        /// </summary>
        [Display(ResourceType = typeof (Global), Name = "MainModel_Traveler_Discount")]
        [DataMember]
        public ListableItem Discount { get; set; }

        public int AgeValue
        {
            get { return int.Parse(Age.SelectedItem.Value); }
        }

        public bool HasDiscount
        {
            get { return int.Parse(Discount.SelectedItem.Value) > 0; }
        }

        public bool Equals(TravelerModel other)
        {
            return GetHashCode() == other.GetHashCode();
        }
    }
}